class Solution {
public:
    int num5 = 0, num10 = 0;

    bool ret5() {
        if(num5 > 0) {
            num5 --;
            return true;
        } else return false;
    }

    bool ret15() {
        if (num10 > 0 && num5 > 0) {
            num10 --; num5 --;
            return true;
        }
        if (num5 >= 3) {
            num5 -= 3;
            return true;
        }
        return false;
    }

    bool lemonadeChange(vector<int>& bills) {
        for(int bill: bills) {
            switch(bill){
            case 5:
                num5 ++;
                break;
            case 10:
                if (ret5()) {
                    num10++;
                    break;
                } else return false;
            case 20:
                if(ret15()) break;
                else return false;
            }
        }
        return true;
    }
};